package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.live.AttentionUserFrom;
import one.stand.request.live.ShortVideoDataForm;
import one.stand.request.live.ShortVideoQuery;
import one.stand.response.live.ShortVideoResponse;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 短视频业务
 * @author luoyang
 * @date 2020/5/20 11:56
 */
@Slf4j
@RestController
@RequestMapping("userApi/shortVideo")
@Api(description = "短视频业务",tags="短视频管理")
public class ShortVideoController extends BaseController{

    /**
     * 分页查询
     * @param request
     * @return
     */
    @PostMapping("queryPage")
    @ApiController(isLogin = false, company = true,paramClass = ShortVideoQuery.class)
    @ApiOperation(value = "分页查询短视频")
    public ResultModel queryPage(@RequestAttribute  ShortVideoQuery request){
        //只查询1 上架的视频
        request.setState(1);
        return crmFegin.queryShortVideoByList(request);
    }


    /**
     * 更新视频浏览数据 包括点赞 转发 播放量
     * @param request
     * @return
     */
    @ApiOperation(value = "更新视频浏览数据 包括点赞 转发 播放量")
    @ApiController(isLogin = false, company = true,card = true,paramClass = ShortVideoDataForm.class)
    @PostMapping("updateData")
    public ResultModel<Boolean> updateData(@RequestAttribute  ShortVideoDataForm request){
        return this.crmFegin.updateData(request);
    }

    /**
     *  关注
     * @param request
     * @return
     */
    @PostMapping("addAttentionUser")
    @ApiOperation(value = "关注")
    @ApiController(isLogin = true, company = true,card = true,paramClass = AttentionUserFrom.class)
    public ResultModel<Boolean> addAttentionUser(@RequestAttribute  AttentionUserFrom request){
        return crmFegin.addAttentionUser(request);
    }


    @PostMapping("queryById")
    @ApiOperation(value = "查询单个视频详情")
    @ApiController(isLogin = true, company = true,card = true,paramClass = ShortVideoQuery.class)
    public ResultModel<ShortVideoResponse> queryById(@RequestAttribute ShortVideoQuery request){
        return crmFegin.queryById(request);
    }


}
